<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once(dirname(__FILE__).'/../lib/BasesfGuardUserActions.class.php');

/**
 * User management.
 *
 * @package    symfony
 * @subpackage plugin
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: actions.class.php 7634 2008-02-27 18:01:40Z fabien $
 */
class sfGuardUserActions extends BasesfGuardUserActions
{
	  protected function addFiltersCriteria($c)
	  {
	    if (isset($this->filters['username_is_empty']))
	    {
	      $criterion = $c->getNewCriterion(sfGuardUserPeer::USERNAME, '');
	      $criterion->addOr($c->getNewCriterion(sfGuardUserPeer::USERNAME, null, Criteria::ISNULL));
	      $c->add($criterion);
	    }
	    else if (isset($this->filters['username']) && $this->filters['username'] !== '')
	    {
	      $c->add(sfGuardUserPeer::USERNAME, strtr($this->filters['username'], '*', '%'), Criteria::LIKE);
	    }
	    if (isset($this->filters['group_is_empty']))
	    {
	      $criterion = $c->getNewCriterion(sfGuardUserPeer::GROUP, '');
	      $criterion->addOr($c->getNewCriterion(sfGuardUserPeer::GROUP, null, Criteria::ISNULL));
	      $c->add($criterion);
	    }
	    else if (isset($this->filters['group']) && $this->filters['group'] !== '')
	    {
	      $c->add(sfGuardUserPeer::GROUP, $this->filters['group']);
	    }
	  }
	  
	  public function executePublish($request){
               $this->getResponse()->setTitle('Warehouse-Management');
	  	$id = $request->getParameter('id');
	  	$user = sfGuardUserPeer::retrieveByPK($id) ;
	  	$user->setIsActive(1 - $user->getIsActive());
	  	$user->save();
	  	$this->redirect('sfGuardUser/list');
	  }
}
